<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>js</title>
</head>
<body>
	
	<h1>aaaaaaaaaaaaaaaaaaa</h1>

<script>
	//兼容性，区分浏览器
	nav=navigator.userAgent;
	ntype=nav.match(/chrome|firefox|trident/i);//trident为IE浏览器 获取到的是数组
	switch(ntype[0].toLowerCase()){//toLowerCase将获取内容，转化为小写
		case 'chrome':
			document.body.style.background='#f00'; //红
			break;
		case 'firefox':
			document.body.style.background='#0f0'; //绿
			break;
		case 'trident':
			document.body.style.background='#00f';//蓝
			break;
	}
</script>
</body>
</html>